package com.spring.security.controller;

import com.spring.security.entity.Msg;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * ClassName: HomeController
 * Desc:
 * Date： 2017/5/26
 * Created：shaom
 */
@Controller
public class HomeController {

//    @PreAuthorize("hasPermission('ROLE_ADMIN')")
    @PreAuthorize("hasRole('ROLE_ADMIN')")
    @GetMapping("/")
    public String home(ModelMap modelMap) {
        Msg msg = new Msg("测试标题", "测试内容", "额外信息，只对管理员显示");
        modelMap.addAttribute("msg", msg);
        return "home";
    }
}
